package com.k2data.k2app.util.schedule;

import com.k2data.k2app.service.RedisService;
import org.apache.log4j.Logger;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.stereotype.Component;

/**
 *
 * @Description: 若一个方法一次执行不完下次轮转时则等待改方法执行完后才执行下一次操作
 */
@Component
@DisallowConcurrentExecution
public class QuartzJobAcceptDataFactory implements Job {
	@Override
	public void execute(JobExecutionContext context) throws JobExecutionException{
		Logger logger = Logger.getLogger(QuartzJobAcceptDataFactory.class);
		logger.debug("任务成功运行");
		ScheduleJob scheduleJob = (ScheduleJob)context.getMergedJobDataMap().get("scheduleJobAcceptData");
		logger.debug("任务名称 = [" + scheduleJob.getJobName() + "]");
		RedisService redisService = MyApplicationContextUtil.getBean("redisService");
		try {
			redisService.updateRedisRecord();
		} catch (Exception e) {
			System.out.println("定时任务运行出错"+e.getMessage());
		}
	}
}
